/**
 * @Author: SevDaisy十七散人 
 * @Date: 2020-07-15 03:13:48
 */
package zyy.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import zyy.util.Bus;
import zyy.util.BusinessException;

public class FrmRiderInfo extends JDialog implements ActionListener {
  private static final long serialVersionUID = -1544763493327512880L;

  private JLabel rName = new JLabel("骑手昵称：");
  public JLabel rNameCon = new JLabel();
  private JLabel rLevel = new JLabel("当前职阶：");
  public JLabel rLevelCon = new JLabel();
  private JLabel lName = new JLabel("骑手账户：");
  public JLabel lNameCon = new JLabel();
  private JLabel regTime = new JLabel("注册日期：");
  public JLabel regTimeCon = new JLabel();
  private JLabel wCnt = new JLabel("交付订单总数：");
  public JLabel wCntCon = new JLabel();
  private JLabel wSum = new JLabel("报酬总金额：");
  public JLabel wSumCon = new JLabel();

  private JButton cLevel = new JButton("请求进阶");
  private JButton exit = new JButton("退出");

  private JPanel text = new JPanel();
  private JPanel btns = new JPanel();

  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == this.cLevel) {
      try {
        Bus.riderManager.loadRiderLevel(this);
        Bus.riderManager.loadRiderInfo(this);
      } catch (BusinessException ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
        ex.printStackTrace();
      }
    } else if (e.getSource() == this.exit) {
      this.setVisible(false);
    }
  }

  public FrmRiderInfo() {
    // JDialog 基础设置
    {
      this.setTitle("外卖助手 骑手 信息查询");
      this.setSize(450, 365);
      this.setLocationRelativeTo(null);
      this.setVisible(true);
      Bus.fRiderInfo = this;
    }
    // body 布局
    {
      this.getContentPane().setLayout(new BorderLayout());
      this.getContentPane().add(this.text, BorderLayout.CENTER);
      this.getContentPane().add(this.btns, BorderLayout.SOUTH);
    }
    // text 相关配置
    {
      this.text.setLayout(new GridLayout(6, 2, 10, 10));
      this.text.add(this.rName);
      this.text.add(this.rNameCon);
      this.text.add(this.rLevel);
      this.text.add(this.rLevelCon);
      this.text.add(this.lName);
      this.text.add(this.lNameCon);
      this.text.add(this.regTime);
      this.text.add(this.regTimeCon);
      this.text.add(this.wCnt);
      this.text.add(this.wCntCon);
      this.text.add(this.wSum);
      this.text.add(this.wSumCon);
    }
    // btns 相关配置
    {
      this.btns.setLayout(new FlowLayout(FlowLayout.RIGHT));
      this.btns.add(this.cLevel);
      this.btns.add(this.exit);
      this.cLevel.addActionListener(this);
      this.exit.addActionListener(this);
      Bus.jButtonZYYStyle(this.cLevel);
      Bus.jButtonZYYStyle(this.exit);
    }
    // 内容数据设置
    {
      try {
        Bus.riderManager.loadRiderInfo(this);
      } catch (BusinessException e) {
        JOptionPane.showMessageDialog(null, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
      }
    }
  }
}